   <!DOCTYPE html>
<html>

<head>
  	<#include "/app/es/common/common_css.ftl">

    <title>注册</title>
 
</head>
<body>

 	 
     <#include "/app/es/common/header.ftl">
     
    <div class="content register">
	    <form action="http://es.cga.com.cn/account/onRegister" method="post">
	        <ul class="frm_list">
	            <li>
	         	<span class="ipt ipt_id">
	                <span class="tit">手机号</span>
	                <input name="mobile" id="mobile" value="">
	            </span>
	            </li>
	
	            <li>
	         	<span class="ipt ipt_code2">
	                <span class="tit">验证码</span>
	                <input type="hidden" name="sessionKey" id="sessionKey" value="xurOC2McKP0mLeKt">
	                <input type="text" name="captcha" id="captcha" value="">
	           		<span class="code_img"><img src="<@context/>app/es/images/show_img.png" onclick="window.location.reload();"></span>
	            </span>
	            </li>
	
	            <li>
	         	<span class="ipt ipt_code">
	                <span class="tit">短信验证码</span>
	                <input type="text" name="smscode" id="smscode" value="">
	                <input type="hidden" name="requestId" id="requestId" value="">
	                <a href="javascript:;" class="lnk_code getsms">获取短信验证码</a>
	            </span>
	            </li>
	
	            <li>
	            <span class="ipt ipt_pwd">
	                <span class="tit">设置密码</span>
	                <input type="password" name="password" id="password">
	            </span>
	            </li>
	
	            <li>
	            <span class="ipt ipt_pwd2">
	                <span class="tit">确认密码</span>
	                <input type="password" name="password2" id="password2" value="">
	                <span class="error hide">两次输入密码不一致</span>
	            </span>
	            </li>
	        </ul>
	        <p class="btns"><button type="button" class="btn btn_submit">注册</button></p>
	        <p class="lnks">
	            阅读并接受 <a href="#" class="lnk_agree" target="_blank">&lt;ES通行证用户服务协议&gt;</a>
	        </p>
	    </form>
	</div>
    
    <#assign tabbarSelect="user">
    <#include "/app/es/common/tabbar.ftl">
    
     <#include "/app/es/common/common_js.ftl">
    
    <script>
      	   $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
 
		    $(".getsms").click(function(){
		        var mobile =  $("#mobile").val();
		        var captcha =  $("#captcha").val();
		        var sessionKey =  $("#sessionKey").val();
		        var isMobile = Func.checkFormat(mobile,'mobile');
		        if( isMobile!==true){
		            alert(isMobile);
		            return;
		        }
		        if( !captcha ){
		            alert('请输入验证码');
		            return;
		        }
		        var ret = Func.oldajax('/account/GetSms',{'mobile':mobile,'captcha':captcha,'sessionKey':sessionKey});
		        if(ret.errno){
		            alert(ret.data);
		            window.location.reload();
		        }else{
		            $("#requestId").val(ret.data);
		            alert('已发送');
		        }
		        return;
		    });
		
		    $(".btn_submit").click(function(){
		        var mobile = $("#mobile").val();
		        var smscode =$("#smscode").val();
		        var password = $("#password").val();
		        var password2 = $("#password2").val();
		        var requestId = $("#requestId").val();
		        if(!mobile){
		            alert('请输入手机号');
		            return false;
		        }
		        var isMobile = Func.checkFormat(mobile,'mobile');
		        if(isMobile!==true){
		            alert(isMobile);
		            return false;
		        }
		        if(!smscode){
		            alert('请输入短信验证码');
		            return false;
		        }
		        //密码规则验证
		        var patrn = /[^a-z0-9A-Z]/;
		        if(patrn.exec(password)){
		            alert('密码只能为字母,数字');
		            return false;
		        }
		        if(password.length<4 || password.length>20){
		            alert('密码长度为4-20位');
		            return false;
		        }
		        if(password!==password2){
		            alert('两次输入密码不一致');
		            return false;
		        }
		        Func.ajax('/account/OnRegister',{'mobile':mobile,'smscode':smscode,'password':password,'password2':password2,'requestId':requestId},RegCallBack);
		    });
		
		    function RegCallBack(ret){
		        if(ret.errno){
		            alert(ret.data);
		            return;
		        }else{
		            alert(ret.data);
		            window.location.href = '/user';
		            return;
		        }
		    }

		</script>
  </body>
</html>
 
